package com.zhuss.controller.product;

import com.zhuss.bean.bo.product.site.ContainSiteBo;
import com.zhuss.bean.unit.product.StrategyRequest;
import com.zhuss.bean.unit.product.TicketRequest;
import com.zhuss.common.BaseController;
import com.zhuss.exception.DzcxException;
import com.zhuss.product.line.ProductReadService;
import com.zhuss.product.site.SiteReadServiceExt;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.*;

/**
 * @author summer
 * @date 2021/1/6 17:32
 */

@RestController
@RequestMapping("/product")
public class ProductController extends BaseController {

    @Autowired
    @Qualifier("productReadService")
    private ProductReadService productReadService;


    @Autowired
	@Qualifier("siteReadServiceExt")
	private SiteReadServiceExt siteReadServiceExt;

    /**
     * 根据起始、线路类型查询策略
     * @param req
     * @return
     */
    @ResponseBody
    @PostMapping("/query/line")
    public Object queryTicket(@RequestBody TicketRequest req) throws DzcxException {
        return productReadService.queryTicket(req);
    }

    /**
     * 根据线路类型查询策略
     */
    @ResponseBody
    @PostMapping("/query/lineByType")
    public Object queryTicketByLineType(@RequestBody TicketRequest req) throws DzcxException {
        return productReadService.queryTicketByLineType(req);
    }

    @ResponseBody
    @PostMapping("/query/containSite")
    public Object containSite(@RequestBody ContainSiteBo bo) throws DzcxException {
    	Object result = siteReadServiceExt.containSite(bo);
		return result;
    }

    /**
     * 根据策略id查询站点信息
     * @param req
     * @return
     * @throws DzcxException
     */
    @ResponseBody
    @PostMapping("/query/siteInfo")
    public Object querySiteInfo(@RequestBody StrategyRequest req) throws DzcxException {
        Object result = productReadService.querySiteInfo(req);
        return result;
    }


    /**
     * 根据策略id查询班次信息
     * @param req
     * @return
     * @throws DzcxException
     */
    @ResponseBody
    @PostMapping("/getTrainInfo")
    public Object queryTrainDate(@RequestBody StrategyRequest req) throws DzcxException {
        Object result = productReadService.queryTrainDate(req.getLineStrategyId());
        return result;
    }

    /**
     * 查询热门线路
     * @param
     * @return
     * @throws DzcxException
     */
    @ResponseBody
    @PostMapping("/query/hotLine")
    public Object queryHotLine() throws DzcxException {
        Object result = productReadService.queryHotLine();
        return result;
    }



}
